import java.lang.reflect.InvocationHandler;

import java.lang.reflect.Proxy;

public class Main {
    public static void main(String[] args) {
        //动态代理  jdk方法
        UserService userService = new UserServiceImpl();
        InvocationHandler handler = new UserInvocationHandler(userService);
        UserService userServiceProxy = (UserService) Proxy.newProxyInstance(userService.getClass().getClassLoader(),userService.getClass().getInterfaces(),handler);

        userServiceProxy.callName("laowang");
    }
}
